# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-easy-format
_pkgname=easy-format
pkgver=1.3.3
pkgrel=1
pkgdesc="Pretty-printing library for OCaml"
url="https://mjambon.github.io/mjambon2016/easy-format.html"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-3-Clause"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune ocaml ocaml-findlib"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-community/easy-format/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build @install
}

check() {
	dune runtest
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
697f4143750320e4f02360e61fb2e5fa4ad41091a87aa997beaf0275d5d6e91d57b13c6578f1f2dca09dd4ff1a09a5922cf805ab0611aca5357757911f6d1bcb  ocaml-easy-format-1.3.3.tar.gz
"
